<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class AdminUserModelResource extends JsonResource
{
    /**
     * @param $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            'id'            => $this->id,
            'openid'        => $this->openid,
            'username'      => $this->username,
            'nickname'      => $this->nickname,
            'access_token'  => $this->access_token,
            'department'    => $this->department,
            'permissions'   => array_filter(explode(',', $this->role)),
        ];
    }
}
